/**
 * File: 
 * Proj/Lab:
 * Author:
 * Date:
 * Section:
 * Email:
 */
package clientGUI.studentGUI;

import java.util.*;
import javax.swing.*;

import clientApp.Plan;
import clientApp.VirtualAdvisor;

public class StudentLoad {
		
	public static Plan getPlanFromUser(VirtualAdvisor myVA) throws Exception
	{
		JPanel myJP = new JPanel();
		String[] pN;
		
		ArrayList<String> planNames = myVA.getPlanNames();
		if(planNames != null)
		{
			pN = new String[planNames.size()];
		
			for(int i = 0; i < planNames.size(); i++)
				pN[i] = planNames.get(i);
		
			String planName = (String)JOptionPane.showInputDialog(myJP,
	                "Select the plan you would like to open:",
	                "Load Plan",
	                JOptionPane.PLAIN_MESSAGE,
	                null,
	                pN,
	                pN[0]);
			
			Plan loadedPlan = myVA.getPlan(planName);
			return loadedPlan;
		}
		else
			throw new Exception("No Plans to Load");
	}
}
